

package com.hazelcast.internal.serialization.impl.defaultserializers;

import com.hazelcast.internal.serialization.impl.SerializationConstants;
import com.hazelcast.nio.ObjectDataInput;

import java.io.IOException;
import java.util.ArrayDeque;

/**
 * The {@link ArrayDeque} serializer
 */
public class ArrayDequeStreamSerializer<E> extends AbstractCollectionStreamSerializer<ArrayDeque<E>> {

    @Override
    public int getTypeId() {
        return SerializationConstants.JAVA_DEFAULT_TYPE_ARRAY_DEQUE;
    }

    @Override
    public ArrayDeque<E> read(ObjectDataInput in) throws IOException {
        int size = in.readInt();

        ArrayDeque<E> collection = new ArrayDeque<>(size);

        return deserializeEntries(in, size, collection);
    }
}
